﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Ether.Libs
{
    public static class Resources
    {
        //Cell Stuff
        public static Effect MapShader;
        public static Model[] TileModels;
        public static Texture2D[] SelectionGrids;
        public static List<Texture2D> TileTextures;

        //Structure Stuff
        public static Effect StructureShader;        

        //METHODS        
        public static void LoadData(Game game)
        {
            MapShader = game.Content.Load<Effect>("fx/tileshader");

            TileModels = new Model[2];
            TileModels[0] = Resources.LoadModel(game, ref MapShader, "assets/map/cell");
            TileModels[1] = Resources.LoadModel(game, ref MapShader, "assets/map/EthrealRamp");
            
            SelectionGrids = new Texture2D[2];
            SelectionGrids[0] = game.Content.Load<Texture2D>("art/map/cellselection");
            SelectionGrids[1] = game.Content.Load<Texture2D>("art/map/EthrealRamp_Selection");

            TileTextures = new List<Texture2D>();
            TileTextures.Add(game.Content.Load<Texture2D>("art/map/cellgrass")); // 0
            TileTextures.Add(game.Content.Load<Texture2D>("art/map/cellsnow"));
            TileTextures.Add(game.Content.Load<Texture2D>("art/map/cellethreal"));
            TileTextures.Add(game.Content.Load<Texture2D>("art/map/EthrealRamp")); // 3
            TileTextures.Add(game.Content.Load<Texture2D>("art/map/EthrealRamp"));
            TileTextures.Add(game.Content.Load<Texture2D>("art/map/EthrealRamp"));

            StructureShader = game.Content.Load<Effect>("fx/structshader");
        }
        public static Model LoadModel(Game game, ref Effect fx, string assetName)
        {
            Model newModel = game.Content.Load<Model>(assetName);

            foreach (ModelMesh mesh in newModel.Meshes)
                foreach (ModelMeshPart meshPart in mesh.MeshParts)
                    meshPart.Effect = fx.Clone();

            return newModel;
        }
    }
}
